home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr45 / protsbm.zip / PROTEU.ZIP / PROTCONV.C < prev    next >
C/C++ Source or Header  |  1990-02-05  |  1KB  |  63 lines

  1. /*    ProtConvert is written by Phil Saunders
  2.  
  3.       ProtConvert expects the following command line:
  4.  
  5.       Convert infile outfile 
  6.  
  7.       infile is the file to be converted,
  8.       outfile is the converted file,
  9.       
  10. */
  11.  
  12. #include <stdio.h>
  13.  
  14. main(argc, argv)
  15. int argc;
  16. char *argv[];
  17.  
  18. {
  19.    FILE *infile, *outfile;
  20.  
  21.    int i, j, c, ret;
  22.  
  23.    infile = fopen(argv[1], "r");               /*open Input file*/
  24.       if (infile == NULL)  {
  25.          printf("Couldn't open input file\n");
  26.          fclose(infile);
  27.          return NULL;
  28.       }
  29.  
  30.    outfile = fopen(argv[2], "wb+");            /*open Output file*/
  31.       if (outfile == NULL)  {
  32.          printf("Couldn't open output file\n");
  33.          fclose(infile);
  34.          fclose(outfile);
  35.          return NULL;
  36.       }
  37.  
  38.    ret = fseek(infile, 7, 0);
  39.     
  40.    for (j = 1; j < 265; j++) {
  41.  
  42.       for (i = 1; i < 257; i++) {
  43.  
  44.          c = fgetc(infile);
  45.          if (c == EOF) {
  46.             printf("File too short to retrieve all voices\n");
  47.             return EOF;
  48.          }
  49.          ret = fputc(c, outfile);
  50.          if (ret == EOF) {
  51.             printf("Error writing output file\n");
  52.             return EOF;
  53.          }
  54.       }
  55.      ret = fseek(infile, 9, 1);
  56.    }   
  57.  
  58.      ret = fclose(infile);    /* close files*/
  59.      ret = fclose(outfile);
  60.    return 0;
  61. }
  62.  
  63.